C Programming


Q21.

The output of the following program is main() { static int x[] = {1,2,3,4,5,6,7,8} int i; for (i=2; i<6; ++i) x[x[i]]=x[i]; for (i=0; i<8; ++i) printf("%d", x[i]); }
GateOverflow

Q22.

Consider the following declaration: int a, *b=&a, **c=&bThe following program fragment a=4; **c=5;
GateOverflow

Q23.

Consider the following C program. #include < stdio.h > int main( ) { static int a[ ] = {10, 20, 30, 40, 50}; static int *p[ ] = {a, a+3, a+4, a+1, a+2}; int **ptr = p; ptr++; printf("%d%d", ptr-p,**ptr); }The output of the program is ______________.
GateOverflow

Q24.

Consider the following C program segment. #include < stdio.h > int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); } What will be printed by the program?
GateOverflow

Q25.

What does the following fragment of C-program print? char c []="GATE2011"; char *p =c; printf ("%s", p + p[3]- p[ 1 ]);
GateOverflow

Q26.

What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory. int main () { unsigned int x[4][3] ={{1,2,3},{4,5,6},{7,8,9},{10,11,12}}; printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3); }
GateOverflow

Q27.

Consider the following program in C language: # include < stdio.h > main() { int i; int * pi = &i scanf( "%d", pi) ; printf ("%d \ n", i+5) ; } Which one of the following statements is TRUE?
GateOverflow

Q28.

Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j, k; i = 0; j = n-1; do { k = (i+j)/2; if (x <= listA[k]) j = k-1; if (listA[k] <= x) i = k+1; }while (i <= j); if (listA[k] == x) return(k); else return -1; } Which one of the following statements about the function ProcessArray is CORRECT?
GateOverflow

Q29.

Which of the following is an illegal array definition?
GateOverflow

Q30.

What is the output printed by the following C code? #include < stdio.h > int main () { char a [6] = "world"; int i, j; for (i = 0, j = 5; i < j; a [i++] = a [j--]); printf ("%s\n", a); }
GateOverflow